﻿using BCCServer.DAO.chat;
using BCCServer.DAO.Interfaces;
using BCCServer.Model.Enums;
using BCCServer.Model.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace BCCServer.Service.ChatService
{
    public class Chat : BCCServer.IService.IChatService.IChat
    {
        private readonly IchatDB ichatDB;

        public Chat(IchatDB ichatDB)
        {
            this.ichatDB = ichatDB;
        }

        /// <summary>
        /// 根据账号查询聊天信息
        /// </summary>
        /// <param name="sendAccount"></param>
        /// <param name="receiveAccount"></param>
        /// <returns></returns>
        public List<UChatinfo> selChatinfo(string sendAccount, string receiveAccount)
        {
            return ichatDB.selChatinfo(sendAccount, receiveAccount);
        }

        /// <summary>
        /// 添加聊天信息
        /// </summary>
        /// <param name="uChatinfo"></param>
        /// <returns></returns>
        public int addChatinfo(UChatinfo uChatinfo)
        {
            return ichatDB.addChatinfo(uChatinfo);
        }

        /// <summary>
        /// 根据账号查询好友
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public List<UFriend> selFriendsinfo(string account)
        {
            return ichatDB.selFriendsinfo(account);
        }

        /// <summary>
        /// 根据账号查询未读消息
        /// </summary>
        /// <param name="sendAccount"></param>
        /// <returns></returns>
        public List<UChatinfo> selChatAllUnreadinfo(string receiveAccount)
        {
            return ichatDB.selChatAllUnreadinfo(receiveAccount); 
        }
    }
}
